<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC2140 – Word is of the form `"A"B"C"` (B indicated). Did you mean `"ABC"` or `"A\\"B\\"C"`?</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC2140 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC2140">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2
id="word-is-of-the-form-abc-b-indicated-did-you-mean-abc-or-abc">Word is
of the form <code>"A"B"C"</code> (B indicated). Did you mean
<code>"ABC"</code> or <code>"A\\"B\\"C"</code>?</h2>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="SC2140.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;&lt;img src=&quot;</span>foo.png<span class="st">&quot; /&gt;&quot;</span> <span class="op">&gt;</span> file.html</span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC2140.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="st">&quot;var&quot;</span>=<span class="st">&quot;42&quot;</span></span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="SC2140.html#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;&lt;img src=</span><span class="dt">\&quot;</span><span class="st">foo.png</span><span class="dt">\&quot;</span><span class="st"> /&gt;&quot;</span> <span class="op">&gt;</span> file.html</span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="SC2140.html#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="st">&quot;var=42&quot;</span></span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>This warning triggers when an unquoted literal string is found
suspiciously sandwiched between two double quoted strings.</p>
<p>This usually indicates one of:</p>
<ul>
<li>quotes that were supposed to be nested, and therefore need to be
escaped (like the <code>&lt;img&gt;</code> example)</li>
<li>quotes that are just plain unnecessary (like the <code>export</code>
example).</li>
</ul>
<p>Without escaping, the inner two quotes of the sandwich (the end quote
of the first section and the start quote of the second section) are
no-ops. The following two statements are identical, so the quotes that
were intended to be part of the html output are instead removed:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="SC2140.html#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;&lt;img src=&quot;</span>foo.png<span class="st">&quot; /&gt;&quot;</span> <span class="op">&gt;</span> file.html</span>
<span id="cb5-2"><a href="SC2140.html#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;&lt;img src=foo.png /&gt;&quot;</span> <span class="op">&gt;</span> file.html</span></code></pre></div>
<p>Similarly, these statements are identical, but work as intended:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="SC2140.html#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="st">&quot;var&quot;</span>=<span class="st">&quot;42&quot;</span></span>
<span id="cb6-2"><a href="SC2140.html#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="st">&quot;var=42&quot;</span></span></code></pre></div>
<h3 id="exceptions">Exceptions</h3>
<p>If you know that the quotes are ineffectual but you prefer it
stylistically, you can ignore this message.</p>
<p>It's common not to realize that double quotes can span multiple
elements, or to stylistically prefer to quote individual variables. For
example, these statements are identical, but the first is laboriously
and redundantly quoted:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="SC2140.html#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">http://</span><span class="st">&quot;</span><span class="va">$user</span><span class="st">&quot;</span><span class="ex">:</span><span class="st">&quot;</span><span class="va">$password</span><span class="st">&quot;</span><span class="ex">@</span><span class="st">&quot;</span><span class="va">$host</span><span class="st">&quot;</span><span class="ex">/</span><span class="st">&quot;</span><span class="va">$path</span><span class="st">&quot;</span></span>
<span id="cb7-2"><a href="SC2140.html#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="st">&quot;http://</span><span class="va">$user</span><span class="st">:</span><span class="va">$password</span><span class="st">@</span><span class="va">$host</span><span class="st">/</span><span class="va">$path</span><span class="st">&quot;</span></span></code></pre></div>
<p>When ShellCheck detects the first style (i.e. the double quotes
include only a single element each), it will suppress the warning.</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


